package org.yi.fc.enums;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;

/**
 * 文章状态枚举
 * @author ilgqh
 *
 */
public enum PostStatusEnum {

	PUBLISH("publish","已发布"),
	FORBID("forbid","已禁用"),
	UNPUBLISHED("unpublished","待审核"),
	DELETE("delete","已删除");
	
	private String name;
	private String desc;
	
	private PostStatusEnum(String name, String desc) {
		this.name = name;
		this.desc = desc;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	public PostStatusEnum parseEnum(String name){
		Preconditions.checkNotNull(Strings.emptyToNull(name), "传入的状态值不允许为空!");
		for(PostStatusEnum status : values()){
			if(Objects.equal(name, status.getName())) {
				return status;
			}
		}
		return null;
	}
	
}
